﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using FreightSoft.BusinessLogicLayer.ORDER;
using FreightSoft.Modules;

namespace FreightSoft.Controllers
{
    public class AccountController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(User user)
        {
            if (UserCheckModule.ValidateUser(user.UserId, user.Password))
            {
                FormsAuthentication.SetAuthCookie(user.UserId, false);
                return RedirectToAction("Index", "Home");
            }
            else
            {
                ViewBag.error = "Please provide valid user name and password.";
                return View();
            }
        }

        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();

            return RedirectToAction("Index", "Home");
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
    }
}